precision mediump float;
varying vec2 v_texCoord;
varying vec3 worldpos;
uniform sampler2D s_texture;
uniform sampler2D normalmap;

void main()
{
    vec3 normal = texture2D(normalmap, v_texCoord).rgb*2.0-1.0;

    vec3 dir = vec3(30, 40, 350)-worldpos;
	
	float strength = 5000.0;
	
	float att = clamp(1.0-length(dir)/strength, 0.0, 1.0);
    dir = normalize(dir);
    float diffuse = dot(normal, dir)*att;
    
    gl_FragColor = texture2D(s_texture, v_texCoord);
    gl_FragColor *= vec4(diffuse*2.0, diffuse*2.0, diffuse*2.0, 1);
}

